using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models.DAO.Interfaces;
using FiltronASP.Models;

namespace FiltronASP.Modules
{
    public class bottomMenuModule : AbstractModule
    {

        /// <summary>
        /// Klasa odpowiedzialna za generowanie contentu przez modul.
        /// </summary>
        /// <param name="page">biezaca strona</param>
        /// <returns>content</returns>
        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            string htmlToReturn = "<ul>";

            int languageId = Convert.ToInt32(page.language_id);
            string MenuName = "Menu dolne";

            Models.DAO.MenuItemDAO menuItemDAO = new FiltronASP.Models.DAO.MenuItemDAO();
            int itemCounter = 1;
            IQueryable<MenuItem> menuItems = menuItemDAO.FindByLanguageIdAndMenuNameAndItemPublished(languageId, MenuName, true);
            if (menuItems != null)
            {
                foreach (var someItem in menuItems)
                {
                    htmlToReturn += string.Format("<li><a href=\"{0}\">{1}</a></li>", someItem.item_link, someItem.item_name);
                    itemCounter++;
                }
            }

            htmlToReturn += "</ul>";
            return htmlToReturn;
        }
    }
}
